package com.example.tongyiwanxiangdemo.draw.service.impl;

import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.example.tongyiwanxiangdemo.draw.pojo.DrawPO;
import com.example.tongyiwanxiangdemo.draw.service.DrawService;
import org.springframework.stereotype.Service;

/**
 * @author xiaoshan
 */
@Service
public class DrawServiceImpl implements DrawService {


    /**
     * 同步绘画
     *
     * @param drawPo drawPo
     */
    @Override
    public void drawWithSynchronization(DrawPO drawPo) throws ApiException, NoApiKeyException {
        ImageSynthesis is = new ImageSynthesis();
        ImageSynthesisParam param =
                ImageSynthesisParam.builder()
                        .model(ImageSynthesis.Models.WANX_V1)
                        .n(4)
                        .size("1024*1024")
                        .prompt(drawPo.getPrompt())
                        .build();

        ImageSynthesisResult result = is.call(param);
        System.out.println(result);
    }
}
